package pl.lodz.p.browarex.contoller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import pl.lodz.p.browarex.model.IngredientOrderRequest;
import pl.lodz.p.browarex.model.ProductOrder;
import pl.lodz.p.browarex.service.GenericService;


@Controller
@RequestMapping("orders")
public class OrdersController {
	@Autowired
	private GenericService<ProductOrder, Long> productOrderService;
	@Autowired
	@Qualifier("IngredientOrderRequestService")
	private GenericService<pl.lodz.p.browarex.model.IngredientOrderRequest, Long> ingredientOrderService;
	
	@RequestMapping()
	public ModelAndView showLoginPage(Model model) throws Exception {
		ModelAndView mav = new ModelAndView("orders");
		List<ProductOrder> productOrders = productOrderService.list();
		List<IngredientOrderRequest> ingredientRequests = ingredientOrderService.list();
		mav.addObject("productOrders",productOrders);
		mav.addObject("ingredientsOrders", ingredientRequests);
		return mav;
	}
}
